<script setup>
import { ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getSearchList } from "../../apis/music";
import { createWindow } from "../../utils/ipcRenderer";

const props = defineProps(["albumList"]);

const handleAlbum = (id) => {
  createWindow({
    windowName: "albumDetail",
    path: "albumDetail",
    width: 1200,
    height: 820,
    param: { id: id },
  });
};
</script>

<template>
  <div v-if="albumList" class="singer_album">
    <div class="content_wrap">
      <div class="content">
        <div
          v-for="(item, index) in albumList"
          :key="index"
          style="position: relative"
          class="image"
        >
          <div @click="handleAlbum(item.id)" class="image_wrap">
            <el-image
              fit="cover"
              lazy
              :src="item.picUrl ? item.picUrl+`${'?param=300y300'}}` : item.coverImgUrl+`${'?param=300y300'}}`"
            >
            </el-image>
          </div>

          <span class="name">{{ item.name }}</span>
          <span>{{ item.artist.name }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.singer_album {
  width: 100%;
  .content_wrap {
    position: relative;
    // margin-top: 20px;
    width: 45vw;
    .content {
      // display: flex;
      // flex-wrap: wrap;
      display: grid;
      justify-content: space-around;
      grid-template-columns: repeat(auto-fill, 12vw);

      .image {
        margin-bottom: 45px;
        .image_wrap {
          position: relative;
          height: 11vw;

          .el-image {
            height: 100%;
            border-radius: 10px;
          }
          .play_img {
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -25px;
            margin-top: -25px;
            display: none;
            transition: all 1s 1s;
          }
        }
      }
      .image:hover .play_img {
        display: block;
      }
      .name {
        display: block;
        font-size: 16px;
        font-weight: 600;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    .more {
      font-size: 18px;
      font-weight: 600;
      display: flex;
      justify-content: center;
      align-items: center;
      div {
        cursor: pointer;
        background-color: #f7f7f9;
        padding: 10px 20px;
        color: #393939;
        border-radius: 10px;
        transition: 0.5s;
        &:active {
          transform: scale(1.1);
        }
      }
    }
  }
}
</style>
